home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14597 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.spies.com!usenet
  2. From: Erik Max Francis <max@alcyone.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How to initialize array of objects using non-void constructor?
  5. Date: Sun, 31 Mar 1996 20:39:47 -0800
  6. Organization: Alcyone Systems
  7. Message-ID: <315F5E13.799D1B33@alcyone.com>
  8. References: <4jbuo5$mcb@newshost.lanl.gov> <315C8F65.78D5@aai.arco.com>
  9. NNTP-Posting-Host: newton.alcyone.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i486)
  14.  
  15. Brian Leach wrote:
  16.  
  17. > Liang Lu wrote:
  18. > >
  19. > > Example:
  20. > >
  21. > > class Table {
  22. > >         Table() ;
  23. > >         Table(int n) ;
  24. > > ..
  25. > > } ; 
  26. > >
  27. > > Table object[10] ; // default constructor are used here
  28. >
  29. > Sorry Liang, it is not possible. The language does not allow for
  30. > non-default
  31. > constructors for arrays of objects.
  32.  
  33. Nonsense; see Ellis & Stroustrup, 12.6.1.  Using non-default constructors for
  34. initializing an array is much the same as one would expect (using the example
  35. above):
  36.  
  37.     Table object[3] = { object(1), object(1), object(2) };
  38.  
  39. -- 
  40. Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max@alcyone.com
  41. San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect
  42. H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade
  43. Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem
  44. "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_
  45.